OpenCities Map Help

Defining Domain Lists

Domains are restricting the list of possible values to be input by the editor of the data. For example, the Street_Type property could be restricted to just four values: Highway, Primary Road, Secondary Road, and Unpaved Road.

By default, the registration of an spatial table as a feature will define properties as Text properties. To enhance this, the OpenCities Map provides the ability to identify lookup tables in SQL Server and use them as XFM domain lists. This way, properties can be defined as pick lists (Option List Properties).

Configuring tables for use as domain lists is a two-step process:

  • First, a lookup table needs to be either created or already present in the database;

  • Second, a foreign key is added to ‘formalize’ the relationship between the lookup table and the parent table.

The ability to use domain lists based on lookup tables, starts with the creation of a primary table:

CREATE TABLE STREET 
(ID INT IDENTITY(1,1) NOT NULL CONSTRAINT PK_STREET_ID PRIMARY KEY, 
Name VARCHAR(50) NULL, 
Street_Type VARCHAR(20) NULL, 
Geom GEOMETRY NULL)

A lookup table is created that will be linked to the primary table. To link the Street_Type column of the Street table, use the following CREATE TABLE statement:

CREATE TABLE STREET_TYPE_LUT​
(Type VARCHAR(20) NOT NULL,
​Description VARCHAR(64),
​CONSTRAINT STREET_TYPE_LUT PRIMARY KEY(Type))

The table’s alpha column is linked with the Type column in the Street table. The lookup table needs to be populated with the appropriate values. For example using:

INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('AVE', 'Avenue');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('BLVD', 'Boulevard');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('CT', 'Court');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('DR', 'Drive');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('PL', 'Place');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('RD', 'Road');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('ST', 'Street');
INSERT INTO STREET_TYPE_LUT ("TYPE", "DESCRIPTION") VALUES ('TERR', 'Terrace');

With the lookup table in place, a foreign key constraint is added to root table to ensure that the right column in the spatial table is tied to the values in the lookup table.

For example, in the case of the Street and the Street Type lookup tables:

ALTER TABLE STREET
ADD CONSTRAINT STREET_TYPE_LUT_FK
​FOREIGN KEY(Street_Type)
​REFERENCES STREET_TYPE_LUT(Type)

With the lookup table and the foreign key in place, during feature registration the foreign key relationship will be acknowledged by OpenCities Geospatial Administrator. As a consequence:

1.The feature’s property will be of type ComboBox;

2.A domain list entry will be added to the schema;

3.The domain list will be populated.